//新增班级提交按钮
function form_submit(form) {
	recoverFlag();
	if (checkCourseName(form) & checkSchoolYear(form) & checkCourseName(form)
			& checkCredit(form) & checkCourseStart(form) & checkCourseEnd(form)) {
		return true;
	} else {
		return false;
	}
}

// 校验班级名（课程班级）
function checkCourseName(form) {// 必填,且由1-20个汉字、字母、数字、下划线组成
	var courseName = form.courseName;
	var courseName_value = form.courseName.value;
	var span = document.getElementById("courseNameSpanId");
	var regex = /^[a-zA-Z0-9_\u4e00-\u9fa5]{1,20}$/;
	if (regex.test(courseName_value)) {
		span.innerHTML="<img src='images/ok.gif'/>";
		return true;
	} else {
		span.innerHTML = "<img src='images/no.gif'/><font color='red'>必填,且由1-20个汉字、字母、数字、下划线组成</font>";
		courseName.focus();
		return false;
	}
}

// 校验学年
function checkSchoolYear(form) {// 必填
	var schoolYear = form.schoolYear;
	var schoolYear_value = form.schoolYear.value;
	var span = document.getElementById("schoolYearSpanId");
	if (schoolYear_value != -1) {
		span.innerHTML="<img src='images/ok.gif'/>";
		return true;
	} else {
		span.innerHTML = "<img src='images/no.gif'/><font color='red'>必填</font>";
		schoolYear.focus();
		return false;
	}
}

// 校验学期
function checkCourseName(form) {// 必填
	var term = form.term;
	var term_value = form.term.value;
	var span = document.getElementById("termSpanId");
	if (term_value != -1) {
		span.innerHTML="<img src='images/ok.gif'/>";
		return true;
	} else {
		span.innerHTML = "<img src='images/no.gif'/><font color='red'>必填</font>";
		term.focus();
		return false;
	}
}

// 校验学分
function checkCredit(form) {// 必填，且为大于等于零的实数
	var credit = form.credit;
	var credit_value = form.credit.value;
	var span = document.getElementById("creditSpanId");
	if (credit_value > 0) {
		span.innerHTML="<img src='images/ok.gif'/>";
		return true;
	} else {
		span.innerHTML = "<img src='images/no.gif'/><font color='red'>必填，且为大于等于零的实数</font>";
		credit.focus();
		return false;
	}
}

// 校验课程开始周
function checkCourseStart(form) {// 必填,且为正整数
	var courseStart = form.courseStart;
	var courseStart_value = form.courseStart.value;
	var span = document.getElementById("courseStartSpanId");
	var regex = /^[1-9]\d*$/;
	if (regex.test(courseStart_value)) {
		span.innerHTML="<img src='images/ok.gif'/>";
		return true;
	} else {
		span.innerHTML = "<img src='images/no.gif'/><font color='red'>必填,且为正整数</font>";
		courseStart.focus();
		return false;
	}
}

// 校验课程结束周
function checkCourseEnd(form) {// 必填,且为正整数
	var courseEnd = form.courseEnd;
	var courseEnd_value = form.courseEnd.value;
	var span = document.getElementById("courseEndSpanId");
	var regex = /^[1-9]\d*$/;
	if (regex.test(courseEnd_value)) {
		span.innerHTML="<img src='images/ok.gif'/>";
		return true;
	} else {
		span.innerHTML = "<img src='images/no.gif'/><font color='red'>必填,且为正整数</font>";
		courseEnd.focus();
		return false;
	}
}

// 重置按钮
function recoverFlag() {
	var span1 = document.getElementById("courseNameSpanId");
	var span2 = document.getElementById("schoolYearSpanId");
	var span3 = document.getElementById("termSpanId");
	var span4 = document.getElementById("creditSpanId");
	var span5 = document.getElementById("courseStartSpanId");
	var span6 = document.getElementById("courseEndSpanId");
	span1.innerHTML = "*";
	span2.innerHTML = "*";
	span3.innerHTML = "*";
	span4.innerHTML = "*";
	span5.innerHTML = "*";
	span6.innerHTML = "*";
}